function [ar1_gX,vol_gX] = moment_quarterly_growth_ar1(parms,gesol,X_Nxz,Phi_Nxz,prob_Nxz)
% Computes corr(log(X4+X5+X6)-log(X1+X2+X3),log(X7+X8+X9)-log(X4+X5+X6))
% = E[(log(X4+X5+X6)-log(X1+X2+X3))*log(X7+X8+X9)-log(X4+X5+X6)]/Var(log(X4+X5+X6)-log(X1+X2+X3))
% along with its associated moments

    logfun = @(x)log(x);
    logfun2 = @(x)(log(x)).^2;
    
    X_Nxz = reshape(X_Nxz,[parms.NN parms.Nx parms.Nz]);
    
    % 1. compute E[log(X(t)+X(t+1)+X(t+2))|N(t),z(t)]
    m1cond_X = moment_EFX_conditional_Model20220926(parms,gesol,logfun,X_Nxz);
    
    % 2. compute E[log(X(t)+X(t+1)+X(t+2))^2|N(t),z(t)]
    m2cond_X = moment_EFX_conditional_Model20220926(parms,gesol,logfun2,X_Nxz);
    
    % 3. compute E[log(X(t)+X(t+1)+X(t+2))*log(X(t+3)+X(t+4)+X(t+5))|N(t),z(t)]
    EFGX_3 = moment_EFGX_conditional_Model20220926(parms,gesol,@(x)log(x),X_Nxz,reshape(Phi_Nxz*m1cond_X(:),[parms.NN parms.Nx parms.Nz]));
    
    % 4. compute E[log(X(t)+X(t+1)+X(t+2))*log(X(t+6)+X(t+7)+X(t+8))|N(t),z(t)]
    EFGX_6 = moment_EFGX_conditional_Model20220926(parms,gesol,@(x)log(x),X_Nxz,reshape((Phi_Nxz^4)*m1cond_X(:),[parms.NN parms.Nx parms.Nz]));
    
    % mean_gX = sum(prob_Nz(:).*((Phi_Nz^3)*m1cond_X(:) - m1cond_X(:)));
    
    % vol_gX = sqrt(2*sum(prob_Nz(:).*m2cond_X(:)) - 2*sum(prob_Nz(:).*EFGX_3(:)) - mean_gX^2);
    
    vol_gX = sqrt(2*sum(prob_Nxz(:).*m2cond_X(:)) - 2*sum(prob_Nxz(:).*EFGX_3(:)));
    
    ar1_gX = sum(prob_Nxz(:).*(2*EFGX_3(:) - m2cond_X(:) - EFGX_6(:)))/(vol_gX^2);

end